#ifndef SPLITTER_H
#define SPLITTER_H

#include "Cluster.h"
#include "FNF_Types.h"
#include "Pile.h"
#include "Skinner.h"
#include "ID_Generator.h"

// Manages all the details of how a cluster is split into two.
// There are several variations:
// cluster may be split by
// - brute force FNF build, plus graph coloring
// - approximate FNF, using coring by removal of medians
// - approximate FNF, using greedy algorithm to approximate the extreme set

class Splitter {
public:
    Splitter(Skinner *skinner);
    void split(Cluster *parent, Cluster*& A, Cluster*& B);

    fnf_graph_t *build_farthest_neighbor_graph(const Pile& span,
                                               const Pile& extreme_set,
                                               Antipole_Map& antipoles);
    void color_fnf(fnf_graph_t *fnf);
    int partition(fnf_graph_t *graph, Pile& span,
                  Iterator<Item*>& start_of_white_set);

    Skinner *skinner;

private:
    ID_Generator graph_ID;
};

#endif
